package com.lh.dao;

import com.lh.entity.Orders;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: LuoHang
 * @Date: 2021/2/16 0:45
 * @Description
 */
@Repository
public class OrdersDao {
    @Autowired
    private SqlSessionTemplate sessionTemplate;

    public List<Orders> getOrders(Map<String,Object> map){
        return sessionTemplate.selectList("OrdersMapper.getOrders",map);
    }

    public Orders getOrdersById(Map<String,Object> map){
        return sessionTemplate.selectOne("OrdersMapper.getOrders",map);
    }

    public int addOrders(Orders orders){
        return sessionTemplate.insert("OrdersMapper.addOrder",orders);
    }

    public int deleteOrdersById(Integer id){
        return sessionTemplate.delete("OrdersMapper.deleteOrderById",id);
    }

    public int updateOrders(Map<String,Object> map){
        return sessionTemplate.update("OrdersMapper.updateOrder",map);
    }

    public Orders getOrderByOrderNum(String orderNumber){
        return sessionTemplate.selectOne("OrdersMapper.getOrderByOrderNum",orderNumber);
    }
}
